package com.yb.guigu.pick.activity.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.yb.guigu.pick.activity.service.IRedPackageRainService;
import com.yb.guigu.pick.core.bean.GuiguResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/7/15 14:42
 * FileName: RedPackageRainController
 * Description:
 */

@RestController
@Slf4j
@RequestMapping("red_package_rain")
public class RedPackageRainController {


    @Autowired
    IRedPackageRainService redPackageRainService;

    @GetMapping("/generate/{amount}/{count}")
    public GuiguResult generateRain(@PathVariable BigDecimal amount,@PathVariable int count){

        return redPackageRainService.generate(amount,count);
    }



    @GetMapping("/total_money/{redPackageId}/{clickCount}")
    public GuiguResult start(Integer userId,@PathVariable String redPackageId,@PathVariable Integer clickCount) throws JsonProcessingException {
        return redPackageRainService.start(userId,redPackageId,clickCount);
    }


    @GetMapping("/rob/{redPackageRainKey}/{userId}")
    public GuiguResult robRedPackage(@PathVariable  String userId,@PathVariable String redPackageRainKey){
        return redPackageRainService.robRedPackage(userId,redPackageRainKey);
    }


    @GetMapping("/record/{redPackageRainKey}/{userId}")
    public GuiguResult userRedPackageRecord(@PathVariable  String userId,@PathVariable String redPackageRainKey){

        return  redPackageRainService.userRedPackageRecord(userId,redPackageRainKey);
    }
}
